from neo4j import GraphDatabase
import json


# 1. China_中国大陆 地区的电影
def find_movies_in_district(tx, district):
    res = tx.run("MATCH (m:Movie)-[:DISTRICT_OF]->(d:District {name: $district}) RETURN m",
                 {"district": district})
    for it in res.records():
        print(it.get('m')._properties.get('title'))


if __name__ == '__main__':
    driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "123456"))

    with driver.session() as session:
        # 1. 剧情 类 电影
        category = "剧情"
        res = session.run("MATCH (m:Movie)-[:CATEGORY_OF]->(c:Category {name: $category}) RETURN m",
                          {"category": category})
        for it in res.records():
            print(it)
            # print(it._properties)
            # print(it._labels)
            # print(it._id)
        # print(sin[0].graph.nodes)
        # print(sin[0].graph.relationships)
    driver.close()
